<?php
	require_once("../conexion/conexion.php");
	require_once("../Mantenedores/cliente.php");
	$num = $_GET['num'];
	
	$con = new Conexion();
	$con2 = $con->conexionBD("fpproduccion");
	$sql = "select
				UsuNombre,
				h.UsuRut,
				UsuGiro,
				UsuRazonSocial,
				UsuDir,
				UsuFono,
				UsuComuna,
				UsuFax
				
				from Usuario u
				inner join Honorario h on
				u.UsuRut =h.UsuRut 
				
				where HNum='".$num."'";
	$res= mysql_query($sql) or die ($con->error_mysql("Error en la consulta".mysql_error()));
	$datos = mysql_fetch_array($res);
	
	$con = new Conexion();
	$con2 = $con->conexionBD("fpproduccion");
	$sql = "select
				DesNombre,
				DesDir,
				h.DesRut,
				DesComuna,
				RegNombre
				
				from Destinatario d
				inner join Honorario h on
				d.DesRut =h.DesRut
				inner join Region r on
				r.RegCod=d.RegCod
				
				where HNum='".$num."'";
	$res= mysql_query($sql) or die ($con->error_mysql("Error en la consulta".mysql_error()));
	$datos1 = mysql_fetch_array($res);
	
	$con = new Conexion();
	$con2 = $con->conexionBD("fpproduccion");
	$sql = "select
				HNum,
				date_format(HFecha,'%d-%m-%Y') as fecha,
				HGlosa,
				HMonto
				
				from Honorario
				
				where HNum='".$num."'";
	$res= mysql_query($sql) or die ($con->error_mysql("Error en la consulta".mysql_error()));
	$datos2 = mysql_fetch_array($res);
	$retenido = round(($datos2[3]*10)/100);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title></title>
<link href="../Estilos/global.css" rel="stylesheet" type="text/css" />
<link href="../Estilos/local.css" rel="stylesheet" type="text/css" />
<link href="../Estilos/CssTabla3.css" rel="stylesheet" type="text/css" />

<script src="../include_js/jquery.js" type="text/javascript"></script>
<script src="../include_js/popcalendar.js" type="text/javascript"></script>
<style>
.texto
{
	font-size:14px;
	margin-left:8px;
	font:Verdana, Arial, Helvetica, sans-serif; 
	color:#0066CC;
}
.borde
{
	/*border:0px solid #6593C0;*/
	border:1px solid #D3E4E5;
}
.bordeA {	/*border:0px solid #6593C0;*/
	border:1px solid #D3E4E5;
}
</style>
<script>
function Cerrar()
{
	window.close();
}
</script>
</head>

<body>
<a name="arriba"></a>
<br class="end" />
<div id="area">
 <div id="navbar">
    	<div class="righty"></div>
        <div class="lefty"></div>
		<ul>
            <li><label style="font-size:12px;">N&deg; Boleta "<?php echo $num;?>"</label></li>
		</ul>
 </div>
 <div id="content">
<form name="form_exp" id="form_exp" method="post">
<table width="100%" cellpadding="2" cellspacing="0" border="0" class="uno">
<tr>
  <td class="borde" colspan="3"><label class="texto" style="font-weight:bold;">Datos del Emisor.</label></td>
  <td width="33%" class="borde"><input type="hidden" name="txtExp" id="txtExp" value="<?php echo $num;?>" /></td>
</tr>
<tr>
  <td width="19%" class="borde" style="text-align:right"><label class="texto">Nombre:</label></td>
  <td width="40%" class="borde"><input type="text" name="textfield" size="40" value="<?php echo $datos[0]?>" style="background:#E1E1E1" readonly="true" /></td>
  <td width="8%" class="borde" style="text-align:right"><label class="texto">Fono:</label></td>
  <td class="borde"><input type="text" name="textfield3" value="<?php echo $datos[5]?>" style="background:#E1E1E1" readonly="true"/></td>
</tr>
<tr>
  <td class="borde" style="text-align:right"><label class="texto">Rut:</label></td>
  <td class="borde"><input type="text" name="textfield2" value="<?php echo $datos[1]?>" style="background:#E1E1E1" readonly="true"/></td>
  <td class="borde" style="text-align:right"><label class="texto">Fax:</label></td>
  <td class="borde"><input type="text" name="textfield4" value="<?php echo $datos[7]?>" style="background:#E1E1E1" readonly="true"/></td>
</tr>
<tr>
  <td class="borde" style="text-align:right"><label class="texto">Comuna:</label></td>
  <td class="borde"><input type="text" name="textfield5" value="<?php echo $datos[6]?>" style="background:#E1E1E1" readonly="true"/></td>
  <td class="borde" style="text-align:right">&nbsp;</td>
  <td class="borde">&nbsp;</td>
</tr>
<tr>
  <td class="borde" style="text-align:right"><label class="texto">Direcci&oacute;n:</label></td>
  <td class="borde" colspan="3"><input type="text" name="textfield6" value="<?php echo $datos[4]?>" style="background:#E1E1E1" readonly="true" size="80"/></td>
</tr>
<tr>
  <td class="borde" style="text-align:right"><label class="texto">Giro:</label></td>
  <td class="borde" colspan="3"><input type="text" name="textfield7" size="80" value="<?php echo $datos[2]?>" style="background:#E1E1E1" readonly="true"/></td>
</tr>
<tr>
  <td class="borde" style="text-align:right;"><label class="texto">Raz&oacute;n Social:</label></td>
  <td class="borde" colspan="3"><input type="text" name="textfield7" size="80" value="<?php echo $datos[3]?>" style="background:#E1E1E1" readonly="true"/></td>
</tr>

<tr>
  <td class="borde" colspan="4"><hr /></td>
</tr>
<tr>
  <td class="borde" colspan="3"><label class="texto" style="font-weight:bold;">Datos del Destinatario.</label></td>
  <td class="borde">&nbsp;</td>
</tr>
<tr>
  <td class="borde" style="text-align:right"><label class="texto">Nombre:</label></td>
  <td class="borde" colspan="3"><input name="" type="text" size="40" value="<?php echo $datos1[0]?>" style="background:#E1E1E1" readonly="true" /></td>
</tr>
<tr>
  <td class="borde" style="text-align:right"><label class="texto">Rut:</label></td>
  <td class="borde"><input name="" type="text" value="<?php echo $datos1[2]?>" style="background:#E1E1E1" readonly="true" /></td>
  <td class="borde">&nbsp;</td>
  <td class="borde">&nbsp;</td>
</tr>
<tr>
  <td class="borde" style="text-align:right"><label class="texto">Comuna:</label></td>
  <td class="borde"><input name="" type="text" value="<?php echo $datos1[3]?>" style="background:#E1E1E1" readonly="true"/></td>
  <td class="borde">&nbsp;</td>
  <td class="borde">&nbsp;</td>
</tr>
<tr>
  <td class="borde" style="text-align:right"><label class="texto">Regi&oacute;n:</label></td>
  <td class="borde" colspan="3"><input name="" type="text" size="80" value="<?php echo $datos1[4]?>" style="background:#E1E1E1" readonly="true" /></td>
</tr>
<tr>
  <td class="borde" style="text-align:right"><label class="texto">Direcci&oacute;n:</label></td>
  <td class="borde" colspan="3"><input name="" type="text" size="80" value="<?php echo $datos1[1]?>" style="background:#E1E1E1" readonly="true"/></td>
</tr>
<tr>
	<td class="borde" colspan="4"><hr /></td>
</tr>
<tr>
  <td class="borde" colspan="3"><label class="texto" style="font-weight:bold;">Datos de la Boleta.</label></td>
  <td class="borde">&nbsp;</td>
</tr>
<td class="borde" style="text-align:right"><label class="texto">N&deg; Boleta:</label></td>
  <td class="borde" colspan="3"><input name="" type="text" value="<?php echo $datos2[0]?>" style="background:#E1E1E1" readonly="true" /></td>
<tr>
  <td class="borde" style="text-align:right"><label class="texto">Fecha:</label></td>
  <td class="borde" colspan="3"><input name="Input" type="text" value="<?php echo $datos2[1]?>" style="background:#E1E1E1" readonly="true" /></td>
<tr>
  <td class="borde" style="text-align:right"><label class="texto">Glosa:</label></td>
  <td class="borde" colspan="3"><textarea name="txtGlosa" id="txtGlosa" cols="80" rows="3" style="background:#E1E1E1" readonly="true"><?php echo $datos2[2]?></textarea></td>
<tr>
  <td class="borde" style="text-align:right"><label class="texto">Total ($):</label></td>
  <td class="borde" colspan="3"><input name="Input2" type="text" value="<?php echo number_format($datos2[3],0,',','.')?>" style="background:#E1E1E1" readonly="true" /></td>
<tr>
  <td class="borde" style="text-align:right"><label class="texto">10% Ret.:</label></td>
  <td class="borde" colspan="3"><input name="Input3" type="text" value="<?php echo number_format($retenido,0,',','.')?>" style="background:#E1E1E1" readonly="true" /></td>
<tr>
  <td class="borde" colspan="4" style="text-align:center;"><div style="height:3px"></div></td>
</tr>
<tr>
  <td class="borde" colspan="4" style="text-align:center;"><input type="button" name="btn_Cancelar" id="btn_Cancelar" value="Cerrar Ventana" onclick="Cerrar();" /></td>
</tr>
<tr>
  <td class="borde" colspan="4" style="text-align:center;"><div style="height:3px"></div></td>
</tr>
</table>
</form>
 </div>
 <div id="close">
    	<div class="righty"></div>
    	<div class="lefty"></div>
 </div>
</div>
</body>
</html>